﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Data.SqlClient;
namespace 电影售票系统
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string sqlStr = "server=.;database=movie;integrated security=SSPI";
            SqlConnection con = new SqlConnection(sqlStr);
            con.Open();
            string selectsql = "Select * from Table_1 where admin = '" + textBox1.Text + "' and password='" + textBox2.Text + "' ";
            SqlCommand com = new SqlCommand(selectsql, con);
            com.CommandType = CommandType.Text;
            SqlDataReader sdr;
            sdr = com.ExecuteReader();
        
            if (textBox1.Text == string.Empty)
            {
                MessageBox.Show("用户名称不能为空", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (sdr.Read())
            { 
            Form2 f2=new Form2();
            f2.Show();
            this.Hide();
            return;

            }
            else
            {
                MessageBox.Show("用户名或密码不正确！", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
           

        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("您是否退出系统？", "结束", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                Application.Exit();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
